package com.aso114.project.util;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;

/**
 * description:全局拦截点击事件，防止重复点击
 * create at 2019/3/25
 *
 * @author zenghuanxing
 * @email zenghuanxing123@163.com
 */
@Aspect
public class AspectClickFilter {
    private static Long lastClick = 0L;
    private static final Long DELAY_TIME = 600L;

    @Around("execution(* android.view.View.OnClickListener.onClick(..))")
    public void aspectClickFilter(ProceedingJoinPoint joinPoint) {
        if (System.currentTimeMillis() - lastClick >= DELAY_TIME) {
            lastClick = System.currentTimeMillis();
            try {
                joinPoint.proceed();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        } else {
            //Log.e("111111111111111", "重复点击,已过滤");
        }
    }
}